<script lang="ts" setup>
//点击mask消失，由于是页面实际相当于返回
import {onLoad, onShow} from "@dcloudio/uni-app";
import {ref} from "vue";
import {GlobePopupType} from "@/enum/globePopupType";

const popupType = ref<GlobePopupType>(0)
onLoad((option) => {
  title.value = option?.title || '消息通知'
  content.value = option?.content || ''
  popupType.value = option?.type as GlobePopupType ||
      GlobePopupType.MESSAGE
})
const title = ref('')
const content = ref('')
const closeWindow = () => {
  showMask.value = false
  setTimeout(() => {
    uni.navigateBack({
      delta: 1
    })
  }, 50)

}
const moveHandle = () => {
}
const showMask = ref(false)
onShow(() => {
  setTimeout(() => {
    showMask.value = true
  }, 250)
})


const handleUserLocked = () => {
  // 用户账号锁定
  uni.reLaunch({
    url: '/subPkg/login/login'
  })
}


</script>
<template>
  <view :class="['informantion_mask',showMask?'show_mask':'']" @tap="closeWindow"
        @touchmove.stop.prevent="moveHandle">
    <view class="informantion_content" @tap.stop.prevent>

      <!--   正常消息   -->
      <view v-if="popupType===GlobePopupType.MESSAGE.toString()">
        <view class="mask-header">
          <p class="title"></p>
          <image mode="aspectFit" src="/static/cancel.png" @click="closeWindow"></image>
        </view>
        <view class="informantion-title">
          <span class="informantion-title-span">不要错过你的特别关心的重要通知，每天都要有干货推荐</span>
        </view>
        <view class="informantion-btn">
          <button type="primary">去开启</button>
        </view>
      </view>

      <!--   账号异常   -->
      <view v-if="popupType===GlobePopupType.LOCKED.toString()">
        <view class="mask-header">
          <p class="title">账号下线通知</p>
          <image mode="aspectFit" src="/static/cancel.png" @click="closeWindow"></image>
        </view>
        <view class="informantion-title">
          <view class="text-lg text-gray">监测到当前登录账号异常
            <view class="text-red">请重新登录</view>
          </view>
        </view>
        <view class="informantion-btn">
          <uv-button :color="'#39c5bb'" type="primary" @click="handleUserLocked">确定</uv-button>
        </view>
      </view>

      <!--    APP发现新版本  -->
      <view v-if="popupType===GlobePopupType.NEW_VERSION.toString()">
        <view class="mask-header">
          <p class="title">开启消息通知</p>
          <image mode="aspectFit" src="/static/cancel.png" @click="closeWindow"></image>
        </view>
        <view class="informantion-title">
          <span class="informantion-title-span">不要错过你的特别关心的重要通知，每天都要有干货推荐</span>
        </view>
        <view class="informantion-btn">
          <button type="primary">去开启</button>
        </view>
      </view>
    </view>
  </view>
</template>
<style lang="scss">
page {
  width: 100%;
  height: 100%;
  background: transparent;
}

.informantion_mask {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  transition: all 0.1s;
}

.show_mask {
  transition: all 0.1s;
  background: rgba(0, 0, 0, 0.4);
}

.informantion_content {
  width: 600rpx;
  min-height: 200rpx;
  overflow: hidden;
  border-radius: 10px;
  background-color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 20rpx;
}

.mask-header {
  height: 40px;
  position: relative;
  background-repeat: no-repeat;
  background-size: cover;
  display: flex;
  margin-bottom: 20px;
  justify-content: center;

  .title {
    text-align: center;
    padding: 15px;
    font-size: 35rpx;
    font-weight: bold;
  }

  image {
    width: 24px;
    height: 24px;
    position: absolute;
    top: 10px;
    right: 10px;
  }
}

.informantion-title {
  text-align: center;
  padding: 0 40rpx;

  p {
    font-size: 35rpx;
    font-weight: bold;
    line-height: 80rpx;
  }

  span {
    color: #6C6C6C;
  }
}

.informantion-btn {
  height: 90rpx;
  width: 80%;
  margin: 10px auto;
}
</style>